@include('admin.header')

<style type="text/css">
  .opartion {
    width: 350px;
  }

  .pagination {
    list-style: none;
    float: right;
  }

  .pagination li {
    float: left;
    padding-left: 5px;
    padding-right: 5px;
  }

  .input_search {
    margin-top: 10px;
  }
</style>

<div class="wrap">
  <div class="margin-bottom-20">
    <!-- <a class="btn btn-primary edit"><i class="fa fa-plus"></i> 添加</a> -->
    {{ csrf_field() }}
    <input id="change_url" value="" type="hidden"/>
    <form action="{{url('ucenter/ucenter_list')}}" method="post">
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="text-c">
            <input type="text" name="user_account" placeholder="用户账号" style="width:250px" class="input-text input_search" value="{{$user_info->post_nodecode}}">
            <button name="" id="search" class="btn btn-success user_search" type="
            submit"><i class="Hui-iconfont"></i> 搜索</button>
            </span>
            <span class="r">共有数据：<strong>{{$user_info->total()}}</strong> 条</span>
        </div>
    </form>
  </div>
  <form class="form-horizontal js-ajax-form" method="post" novalidate="novalidate">
    <table class="table table-hover table-bordered">
      <thead>
      <tr>
        <th width="100">用户ID号</th>
        <th>用户账号</th>
        <th>用户名</th>
        <th>推荐人</th>
        <th>手机号码</th>
        <th>注册时间</th>
        <th class="opartion">操作</th>
      </tr>
      </thead>
      <tbody>

      @foreach($user_info as $user)
      <tr>
        <td>{{$user->nodeid}}</td>
        <td>{{$user->nodecode}}</td>
        <td>{{$user->nodename}}</td>
        <td>
          @if($user->mobileno == '')
            暂无
          @else
            {{$user->mobileno}}
          @endif
        </td>
        <td>
          @if(is_null($user->mobileno))
            暂无
          @else
            {{$user->mobileno}}
          @endif
        </td>
        <td>{{$user->createtime}}</td>
        <td>
          <a class="vip" _id="{{$user->nodeid}}" nodename="{{$user->nodename}}">VIP套餐</a>|
          <a class="purchar" _id="{{$user->nodeid}}" nodename="{{$user->nodename}}">代购套餐</a>|
          <!-- <a class="direct" _id="{{$user->nodeid}}" nodename="{{$user->nodename}}">直销套餐</a>| -->
          <a class="purse" _id="{{$user->nodeid}}">钱包余额</a>|
          <a class="on_line" _id="{{$user->nodeid}}" nodename="{{$user->nodename}}">线上订单</a>|
          <a class="ucenter_details" _id="{{$user->nodeid}}">详情</a>|
          <a class="user_relation" _code="{{$user->nodecode}}" level="{{$user->level}}">用户关系</a>
        </td>
      </tr>
      @endforeach
      </tbody>
    </table>

    <!-- 分页 -->
    @if (!empty($user_info))
    <div class="page_list">
        {{$user_info->links()}}
    </div>
    @endif
  </form>
</div>

<script>

  $(function(){
    //VIP套餐
  	$('.vip').click(function(){
  	  var id = $(this).attr('_id') || 0;
      var nodename = $(this).attr('nodename');

      //发送异步请求
      $.ajax({
        type: "POST",
        url: "{{url('ucenter/ucenter_vip_cost')}}",
        data: {'id':id,'nodename':nodename},
        success: function(msg){
            if(msg == '暂无数据') {
                _alert('暂无数据');
                return false;
            }
            open_iframe_layer('/ucenter/ucenter_vip_cost?id='+id+'&nodename='+nodename);
        }
      });
    });

    //代购套餐
    $('.purchar').click(function(){
      var id       = $(this).attr('_id') || 0;
      var nodename = $(this).attr('nodename');
      //发送异步请求
      $.ajax({
        type: "POST",
        url: "{{url('ucenter/ucenter_pur_cost')}}",
        data: {'id':id,'nodename':nodename},
        success: function(msg){
          if(msg == '暂无数据') {
            _alert('暂无数据');
            return false;
          }
          open_iframe_layer('/ucenter/ucenter_pur_cost?id='+id+'&nodename='+nodename);
        }
      });
    });

    //直销套餐
    $('a[class="direct"]').click(function(){
      var id = $(this).attr('_id');
      var nodename = $(this).attr('nodename');
      open_iframe_layer('/ucenter/ucenter_direct_cost?id='+id+'&nodename='+nodename);
    });

    //线上订单
    $('.on_line').click(function(){
      var id = $(this).attr('_id');
      var nodename = $(this).attr('nodename');
      //发送同步请求
      $.ajax({
        type: "POST",
        url: "{{url('ucenter/ucenter_online_order')}}",
        data: {'id':id,'nodename':nodename},
        success: function(msg){
            if(msg == '暂无数据') {
                _alert('暂无数据');
                return false;
            }
            open_iframe_layer('/ucenter/ucenter_online_order?id='+id+'&nodename='+nodename);
        }
      });

    });

    //用户详情
    $('.ucenter_details').click(function() {
      var id = $(this).attr('_id');
      open_iframe_layer('/ucenter/ucenter_details?id='+id);
    });

    //钱包余额
    $('.purse').click(function() {
      var id = $(this).attr('_id');
      //发送异步请求，获取用户ticket是否存在
      open_iframe_layer('/ucenter/ucenter_purse?id='+id);
    });

    //用户关系
    $('.user_relation').click(function() {
      var nodecode = $(this).attr('_code');
      var level = $(this).attr('level');
      open_iframe_layer('/ucenter/user_tree?nodecode='+nodecode+'&level='+level);
    });
  });
</script>